<template>
  <div>
    <NavType/>
    <!-- 请求回来的banner数据传递给List组件 -->
    <List :bannerList="bannerList"/>
    <Recommend />
    <Rank />
    <Like />
    <!-- 根据请求回来的floor数据遍历生成Floor组件并传递数据 -->
    <Floor v-for="floor in floorList" :key="floor.id" :floor="floor"/>
    <Brand />
  </div>
</template>

<script>
import List from "./List"
import Recommend from "./Recommend"
import Rank from "./Rank"
import Like from "./Like"
import Floor from "./Floor"
import Brand from "./Brand"

//引入请求floor数据的api
import {requestFloorList} from "@/api"
//引入mock请求
import {requestMockList} from "@/api"
export default {
  name:"Home",
  components:{
    List,
    Recommend,
    Rank,
    Like,
    Floor,
    Brand
  },

  data() {
    return {
      floorList: [],
      bannerList: []
    }
  },

  mounted() {
    //初始化调用函数获取floor数据
      this.getFloorMock()
    
    //初始化调用函数获取banner数据
      this.getBannerMock()
  },

  methods: {
    //请求floor数据的函数
    async getFloorMock(){
      const result = await requestFloorList()
      this.floorList = result
    },

    //请求banner数据的函数
    async getBannerMock(){
      const result = await requestMockList()
      this.bannerList = result
    }
  },
}

</script>

<style scoped lang="less">
</style>